import 'es6-promise/auto';
import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);

import actions from './actions'
import mutations from './mutations'
import getters from './getters'
import member from './modules/member'

const store = new Vuex.Store({
    // @ts-ignore
    strict: false,
    // strict: process.env.NODE_ENV !== 'production',
    modules: {
        member
    },
    state: {
        menus: [],
        userInfo: {
            role_id: 0,
            role_name: '',
            username: '',
            token: ''
        },
        breadCrumb: [],
        policy: {
            host: '',
            OSSAccessKeyId: '',
            policy: '',
            saveName: '',
            signature: ''
        },
        allTips: {},
        memberTips: {
            memberCountMap: {}
        },
        billTips: {},
        orderTips: {},
        reservateBillTips: '',
        tipState: {
            timeStyle: 1,
            billStyleId: '',
            role: '',
            orderBillStyleId: ''
        },
        checkServer: []
    },

    getters,
    mutations,
    actions
});

let userInfo = localStorage.getItem('userInfo'),
    menus = localStorage.getItem('menus');
if (userInfo && menus) {
    store.commit('loginInit', {
        userInfo: JSON.parse(userInfo),
        menus: JSON.parse(menus)
    });
}


export {
    store
}